package com.tangyuan.ai.controller;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tangyuan.ai.entity.dto.DeleteDialogueDTO;
import com.tangyuan.ai.entity.dto.DialogueDTO;
import com.tangyuan.ai.entity.dto.DialogueQueryDTO;
import com.tangyuan.ai.entity.vo.AiDialogueVo;
import com.tangyuan.ai.service.AiDialogueService;
import com.tangyuan.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/ai/aiDialogue")
public class AiDialogueController {

    @Autowired
    AiDialogueService aiDialogueService;


    @GetMapping("getAiDialogueVoByUserId")
    public Result<Page<AiDialogueVo>> getAiDialogueVoByUserId(@RequestHeader("userId") Long userId,
                                                              @ModelAttribute DialogueQueryDTO dto){
        return Result.ok(aiDialogueService.getAiDialogueVoByUserId(userId,dto));
    }

    @PostMapping("sendChat")
    public Result sendChat(@RequestHeader("userId") Long userId,
                           @RequestBody @Validated DialogueDTO dialogueDTO){
        return aiDialogueService.sendChat(userId,dialogueDTO);
    }

    @PostMapping("deleteDialogue")
    public Result deleteDialogue(@RequestHeader("userId") Long userId,
                           @RequestBody List<Long> ids){
        return aiDialogueService.deleteDialogue(userId,ids);
    }

    @PostMapping("deletedDialogue")
    public Result deletedDialogue(@RequestHeader("userId") Long userId,
                           @RequestBody @Validated DeleteDialogueDTO dto){
        return aiDialogueService.deleteDialogue(userId,dto.getIds());
    }

}
